package com.example.controller;

import com.example.po.Sys_Car;
import com.example.po.Sys_City;
import com.example.service.Sys_CarService;
import com.example.vo.CarVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @auter czcjq
 * @date 2022/5/17 15:20
 */
@Controller
@RequestMapping("/car")
public class Sys_CarCtroller {

    @Autowired
    private Sys_CarService sys_carService;

    @ResponseBody
    @RequestMapping(value = "/priceOrNumber",method = RequestMethod.GET)
    public CarVo findcarP(int getid){
        List<Sys_Car> carListp=sys_carService.findCarOrderByPrice(getid);

       /* System.out.println(carListp);*/
            List<Sys_Car> carListn=sys_carService.findCarOrderByNumber(getid);
       /* System.out.println(carListn);*/

        CarVo carVo = new CarVo();
        if(carListp!=null&&carListn!=null){
            carVo.setCode(1);
            carVo.setCarListPrice(carListp);
            carVo.setCarListNumber(carListn);

        }
        return carVo;
    }

    @ResponseBody
    @RequestMapping(value = "/findcar",method = RequestMethod.GET)
    public CarVo getOneCar(int cid){
        Sys_Car oneByID = sys_carService.findOneByID(cid);
        CarVo co=new CarVo();
        if(oneByID!=null){
            co.setCode(1);
            co.setInfo(oneByID);
        }
        return co;
    }

}


